#include <iostream>
using std::cout;
using std::endl;

class A
{
public:
    //声明了一个纯虚函数
    virtual void print() = 0;
    virtual void show() = 0;
};

//B不是抽象类
class B
: public A
{
public:
    void print() override{
        cout << "B::print()" << endl;
    }

    void show() override{
        cout << "B::show()" << endl;
    }
};

//C类是抽象类
class C
: public A
{
public:
    void print() override{
        cout << "C::print()" << endl;
    }
};

class D
: public C
{
public:
    void show() override{
        cout << "D::show()" << endl;
    }
};

void test0(){
    //A类是抽象类，
    //不能创建A类对象
    /* A a1; */

    B b1;
    A * pa = &b1;
    pa->print();
    pa->show();


    //C类也是抽象类，不能创建对象
    /* C c1; */
    /* pa = &c1; */
    /* pa->print(); */

    D d1;
    pa = &d1;
    pa->print();
    pa->show();
}

int main(void){
    test0();
    return 0;
}
